The present invention relates to a circuit for comparing M (M.gtoreq.3) binary numbers.
A conventional circuit for comparing binary inputs compares two numbers. A comparison of two numbers is generally performed by calculating a difference between the two numbers to obtain a relation therebetween. More specifically, assuming that two numbers are A and B, if a difference (A-B) is positive, the relation is A&gt;B; if the difference is negative, it is A&lt;B; and if the difference is 0, it is A=B. This will be described in more detail below with regard to a comparison of two floating-point data with reference to FIG. 1. Referring to FIG. 1, assume that the two floating-point data are A and B, their exponential parts are A.sub.e and B.sub.e, and their mantissa parts are A.sub.m and B.sub.m, respectively. The exponential parts A.sub.e and B.sub.e are supplied to an exponential part calculator 411 to calculate an absolute value .vertline.A.sub.e -B.sub.e .vertline. of a difference between the exponential parts A.sub.e and B.sub.e and a magnitude relation therebetween. The calculation result is supplied as shift information C to a decoder 421. In order to shift the digits of the mantissa part corresponding to a smaller exponential part to correspond to the digits of the mantissa part corresponding to a larger exponential part, the decoder 421 generates and outputs shift amounts D.sub.0 and D.sub.1 of the mantissa parts A.sub.m and B.sub.m, respectively. Shifters 422 and 423 receive the mantissa parts A.sub.m and B.sub.m and the shift amounts D.sub.0 and D.sub.1, respectively, and shift the digits to correspond to each other, and output the results to a subtractor 431. The subtractor 431 performs mantissa part calculation of the floating-point data, and generates and outputs a difference F between the mantissa parts. A judging circuit 441 receives the difference F between the mantissa parts, and generates and outputs a signal G representing a magnitude relation between the numers A and B in accordance with a sign part and parts other than the sign part of the difference F.
A conventional two-input comparator not using a subtractor operates as follows. That is, assuming that two n-bit positive binary numbers (n is an arbitrary natural number) are A=[a.sub.0, a.sub.1, a.sub.2, . . . , a.sub.n-1 ] and B=[b.sub.0, b.sub.1, b.sub.2, . . . , b.sub.n-1 ], and that S and T are given by logic equations: ##EQU1## where is an exclusive NOR, the conventional two-input comparator generates and outputs S, T such that if (S, T)=(1, 0), A&gt;B, if (S, T)=(0, 1), A&lt;B, and if (S, T)=(1,1), A=B.
In the above conventional comparator, however, only two numbers can be compared. Therefore, for example, in order to calculate a minimum value in a set having a large number of elements, calculations must be repeatedly performed until a final result is obtained, resulting in a time-consuming operation. In addition, a number of storage means must be used to hold data.